Skip to content

Conversation

@afalahi
Copy link
Contributor

@afalahi afalahi commented May 15, 2025

  • initial support for org roles.
  • clean up and added grant/revoke
  • emitting org role entitlements and grant counts
  • added org role tests
  • made some comments to review specific sections
  • Supported Features
    • Syncing Org Roles custom and built-in
    • Granting access to users directly to an org role
    • Teams expose the role they have as entitlements
    • Grant source (inheritance) shows how a user got that access
  • This feature requires the Custom organization roles permission
    • Read for syncing
    • Read and Write for Syncing and Provisioning
    • If the permission isn't granted the connector will not error, it will simply not show the org roles or their entitlements

@afalahi afalahi added the enhancement New feature or request label May 15, 2025
Comment on lines 78 to 81
bag, _, err := parsePageToken(pToken.Token, &v2.ResourceId{ResourceType: resourceTypeOrgRole.Id})
if err != nil {
return nil, "", nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove this and always return an empty next token if ListRoles is not paginated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

var ret []*v2.Grant

// First, get teams with this role
teams, resp, err := o.client.Organizations.ListTeamsAssignedToOrgRole(ctx, orgName, roleID, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we will want to use a pagination bag so we can get team assignments/user assignments separately so we paginate properly. An example of how we do this: https://github.com/ConductorOne/baton-okta/blob/81354f306dc69ed74754499a8ea8bb5b234b6943/pkg/connector/group.go#L124

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a new commit to address the pagination

afalahi added 2 commits May 19, 2025 11:41
…moved unnecessary page token parsing and streamlined return values for list and grants functions. Improved handling of permission errors and added pagination logic for teams and users.
…d mock GitHub server to handle paginated responses for teams and users, and updated tests to verify correct handling of grants and pagination scenarios.
@afalahi afalahi requested a review from laurenleach May 19, 2025 17:54
Comment on lines 192 to 198
if len(teams) == pToken.Size {
pageToken, err := bag.NextToken(fmt.Sprintf("%d", page+1))
if err != nil {
return nil, "", nil, err
}
return ret, pageToken, nil, nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we actually set size all the time, and if the token we return is just the page I think it will do the ListTeamsAssignedToOrgRole if theres a second page from ListUsersAssignedToOrgRole. We usually paginate by pushing a page to the bag when we have multiple actions we want to do within a method like here so we can distinguish which action to do

See this example:
https://github.com/ConductorOne/baton-okta/blob/81354f306dc69ed74754499a8ea8bb5b234b6943/pkg/connector/group.go#L124

afalahi added 5 commits May 20, 2025 07:47
…dling. Streamlined resource type checks and enhanced grant creation for users and teams, ensuring proper handling of permission errors and returning accurate annotations.
…erification. Replaced role existence check with a direct API request, improved entitlement ID validation, and streamlined request creation for assigning roles to users.
…nRole. Refactor test cases to utilize the new role data
…e organization role handling. Showing the team > org_role entitlement looks good in the UI but provisioning fails since it's expecting team roles not org roles. We need to think about the right approach before emitting these entitlements
Comment on lines +293 to +297
// First verify that the role exists
req, err := o.client.NewRequest("GET", fmt.Sprintf("orgs/%s/organization-roles/%d", orgName, roleID), nil)
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think we need to do this since the PUT should 404 if it doesn't exist but nbd

@afalahi afalahi merged commit df51929 into main May 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants